import requests
import hashlib
# -------------------------登录------------------------------
# 构造请求头
headers = {

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
    'Content-Type': 'application/json;charset=utf-8'
}
# 'token': ''

# 构造url
base_url = r'https://cloud.huaxiaerp.com/'
url_login = base_url + '/jshERP-boot/user/login'

# 构造data
username = 'Missing'
password = 'h123456'
md5 = hashlib.md5(password.encode())  # 创建MD5对象
password_md5 = md5.hexdigest()  # 调用方法hexdigest加密
data_login = {
    "loginName": username,
    "password": password_md5
}
# 发送情求
resp = requests.post(url_login, json=data_login, headers=headers, verify=False)

# 获取响应
token = resp.json()['data']['token']

headers['X-Access-Token'] = token